package com.srit.recipes.controller;


import com.srit.recipes.common.response.JpaPage;
import com.srit.recipes.common.response.Response;
import com.srit.recipes.entity.RecipesInfo;
import com.srit.recipes.service.BaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "基础数据")
public class BaseController {

    @Autowired
    private BaseService baseService;

    @GetMapping("/base/code")
    @ApiOperation("1 codeInfo表")
    public Response codeInfo() {
        return Response.success(baseService.codeInfo());
    }

    @GetMapping("/base/recipes")
    @ApiOperation("2 菜品表")
    public Response recipesInfo(JpaPage page, RecipesInfo recipesInfo) {
        return Response.success(baseService.recipesInfo(page, recipesInfo));
    }

    @GetMapping("/base/scyy")
    @ApiOperation("3 食材营养成分")
    public Response scyyInfo(JpaPage page, String name) {
        return Response.success(baseService.scyy(page, name));
    }

    @GetMapping("/recipes/ingredient/{recipesId}")
    @ApiOperation("4 菜品成分 主料辅料调料")
    public Response recipesIngredient(@PathVariable String recipesId) {
        return Response.success(baseService.recipesIngredient(recipesId));
    }

    @GetMapping("/recipes/nutrition")
    @ApiOperation("5 菜品营养成分表")
    public Response recipesNutrition(JpaPage page, String name) {
        return Response.success(baseService.recipesNutrition(page, name));
    }

    @GetMapping("/nutrition/standar/{type}")
    @ApiOperation("6 人员营养标准表 type")
    public Response nutritionStandard(JpaPage page, @PathVariable int type) {
        return Response.success(baseService.nutritionStandard(page, type));
    }

}
